package com.xbongbong.paas.enums;

import com.xbongbong.i18n.util.I18nMessageUtil;
import lombok.Getter;

/**
 * 资金账户类型枚举
 * @author zhouwq
 * @date 2020/2/13 10:13
*/
@Getter
public enum FundAccountTypeEnum {

    /**
     * 1-现金账户 2-银行账户 3-支付宝账户 4-微信账户 5-其他账户
     */
    CASH_ACCOUNT(1, "enum.fundAccountType.name.cash_account"),
    BANK_ACCOUNT(2, "enum.fundAccountType.name.bank_account"),
    ALIPAY_ACCOUNT(3, "enum.fundAccountType.name.alipay_account"),
    WECHAT_ACCOUNT(4, "enum.fundAccountType.name.wechat_account"),
    OTHER_ACCOUNT(5, "enum.fundAccountType.name.other_account"),

    UNKNOWN(404, "constant.i18nString.unknow"),
    ;

    /**
     * 类型code值
     */
    private Integer code;

    /**
     * 类型名称
     */
    private String name;


    FundAccountTypeEnum(Integer code, String name){
        this.code = code;
        this.name = name;
    }

    public static FundAccountTypeEnum getByCode(Integer code) {
        for (FundAccountTypeEnum cacheCode : values()) {
            if (code.equals(cacheCode.getCode())) {
                return cacheCode;
            }
        }
        return UNKNOWN;
    }

    public String getName() {
        return I18nMessageUtil.getMessage(name);
    }
}
